//
//  BiddingDriverListCell.m
//  NtoccShipper
//
//  Created by mac on 2019/12/12.
//  Copyright © 2019 zhuchongjin. All rights reserved.
//

#import "BiddingDriverListCell.h"
#import "HCSStarRatingView.h"

@interface BiddingDriverListCell()
@property (nonatomic,strong) HCSStarRatingView *viewRate;
@property (nonatomic,strong) CJView *viewStar;
@property (nonatomic,strong) CJLabel *labPhone;
@property (nonatomic,strong) CJLabel *labName;
@property (nonatomic,strong) CJLabel *labHistoryOrderNums;
@property (nonatomic,strong) CJLabel *labCarNumTitle;
@property (nonatomic,strong) CJLabel *labCarNUm;
@property (nonatomic,strong) CJLabel *labType;
@property (nonatomic,strong) CJLabel *labStarNum;
@property (nonatomic,strong) CJLabel *labPrice;
@property (nonatomic,strong) CJLabel *labWeightNum;
@property (nonatomic,strong) CJLabel *labPriceNum;
@property (nonatomic,strong) CJLabel *labBidTime;
@property (nonatomic,strong) UIView *viewPriceNum;
@property (nonatomic,strong) CJLabel *labSelelcted;
@property (nonatomic,strong) FlexTouchView *touchSelect;
@end

@implementation BiddingDriverListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)setCellInfiWithModel:(BiddDriverListModel *)model{
    [self.viewStar addSubview:self.viewRate];
    self.viewRate.value = model.driverAverage;
    self.labStarNum.text = CJStringWithFormat(@"%.1f",model.driverAverage);
    self.labName.text = model.driverName;
    self.labPhone.text = model.driverPhone;
    self.labHistoryOrderNums.text = CJStringWithFormat(@"历史订单:%ld单",(long)model.historyCount);
    if ([CJRegular getIsStrEmpty:model.vehicleLicenseNumber]) {
        self.labCarNUm.text = model.vehicleLicenseNumber;
        self.labCarNumTitle.hidden = YES;
    }else{
        self.labCarNUm.text = model.vehicleLicenseNumber;
        self.labCarNumTitle.hidden = NO;
    }
    if (model.driverType == 0) {
        self.labType.text = @"  个人  ";
        self.viewPriceNum.hidden = YES;
    }else if (model.driverType == 1){
        self.labType.text = @"  车队  ";
        self.viewPriceNum.hidden = NO;
    }
    
    self.labPrice.text = @(model.bidPrice).cj_money_description;
    self.labPriceNum.text = CJStringWithFormat(@"%ld",(long)model.bidCount);
    self.labWeightNum.text = @(model.bidWeight).cj_description;
    self.labBidTime.text = model.arrivalTime;
    
    if (model.isDeal == 0) {
        self.labSelelcted.hidden = YES;
        self.touchSelect.hidden = NO;
    }else{
        self.labSelelcted.hidden = NO;
        self.touchSelect.hidden = YES;
    }
}

- (void)btnSelelctDriverAction{
    if (self.blockSelect) {
        self.blockSelect(@"");
    }
}

- (HCSStarRatingView *)viewRate{
    if (!_viewRate) {
      _viewRate =   [[HCSStarRatingView alloc]initWithFrame:CGRectMake(0,0,75,30)];
        _viewRate.tintColor = [UIColor cjStarRateColor];
        _viewRate.starBorderColor = [UIColor cjClearColor];
        _viewRate.emptyStarColor = [UIColor cjEmptyStarRateColor];
        _viewRate.backgroundColor = [UIColor cjClearColor];
        _viewRate.enabled = NO;
        _viewRate.maximumValue = 5;
        _viewRate.minimumValue = 0;
        _viewRate.allowsHalfStars = YES;
    }
    return  _viewRate;
}

@end
